﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using CommunitySystem.BO.WordExport;

namespace CommunitySystem.Web.Service
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "WordAction" in code, svc and config file together.
    public class WordAction : IWordAction
    {
        public WordAction()
        {
            bo = new WordExportBO();
            _interBO = new InterviewBO();
            _wagebo = new WagesApprovedBO();
            _postiontBO = new PositionChangeBO();
        }

        public void DoWork()
        {
        }

        
        #region Word_XingZhengJieShaoLetter
        private WordExportBO bo;//= new WordExportBO();
        public string InsertWord_XingZhengJieShaoLetter(CommunitySystemModel.Word_XingZhengJieShaoLetter entity)
        {
            return bo.InsertWord_XingZhengJieShaoLetter(entity);
        }

       

        public bool DeleteWord_XingZhengJieShaoLetter(int id)
        {
            return bo.DeleteWord_XingZhengJieShaoLetter(id);
        }

        public System.Collections.ObjectModel.ObservableCollection<CommunitySystemModel.Word_XingZhengJieShaoLetter> GetXingZhengJieshaoXing(string condition)
        {
            return bo.GetXingZhengJieshaoXing(condition);
        }


        public int GetNOAcoordingToYear(int Year)
        {
            return bo.GetNOAcoordingToYear(Year);
        }
        #endregion

        #region InterviewTemplete
        private InterviewBO _interBO = null;
        public System.Collections.ObjectModel.ObservableCollection<CommunitySystemModel.WordMode.InterviewTemplete> GetInterViewTemplete(string condition)
        {
            return _interBO.GetInterviewTemplete(condition);
        }

        public void SaveInterviewTemplete(CommunitySystemModel.WordMode.InterviewTemplete entity)
        {
            _interBO.InsertInverviewTemplete(entity);
        }

        public void DeleteInterviewTemplete(int id)
        {
            _interBO.DeleteInterviewTemplete(id);
        }

        public string ExportInterviewInfo(string[] Parameters, int TempleteID)
        {
            try
            {
                string path = _interBO.ExportInterviewInfo(Parameters, TempleteID);
                return path;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            
        }

        #endregion

        #region Wages_Approval
        private readonly WagesApprovedBO _wagebo = null;
        public System.Collections.ObjectModel.ObservableCollection<CommunitySystemModel.WordMode.Word_WagesApproved> GetWagesApproved(string condition)
        {
            return _wagebo.GetWagesApproved(condition);
        }

        public void SaveWagesApproved(CommunitySystemModel.WordMode.Word_WagesApproved entity)
        {
            _wagebo.SaveWagesApproved(entity);
        }

        public void DeleteWagesApproved(int id)
        {
            _wagebo.DeleteWagesApproved(id);
        }

        public int GetTopNOAcoordingToYear(int Year)
        {
            return  _wagebo.GetTopNOAcoordingToYear(Year);
        }

        public string ExportWagesApprove(int id)
        {
            try
            {
                var entity = _wagebo.GetWagesApproved("ID=" + id).FirstOrDefault();
                string header = string.Format("No.:{0}[{1}]                                      No.:{0}[{1}]", entity.Year, entity.NO);
                if (string.IsNullOrEmpty(entity.DestDepartment))
                    return _wagebo.ExportExcel(header, entity.Name, entity.OrginalDepartment, entity.OrginalPosition, entity.Reasion, (DateTime)entity.EffectiveDate, entity.AssignDepartment, (DateTime)entity.CeateDate);
                return _wagebo.ExportExcel(header, entity.Name, entity.OrginalDepartment, entity.OrginalPosition, entity.Reasion, entity.DestDepartment, (DateTime)entity.EffectiveDate, entity.AssignDepartment, (DateTime)entity.CeateDate);
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }

        #endregion





        #region Word_PostionChange

        private PositionChangeBO _postiontBO = null;

        public System.Collections.ObjectModel.ObservableCollection<CommunitySystemModel.WordMode.Word_PostionChange> GetWord_PostionChange(string condition)
        {
            return _postiontBO.GetWord_PostionChange(condition);
        }

        public string SaveWord_PostionChange(CommunitySystemModel.WordMode.Word_PostionChange entity)
        {
            return _postiontBO.SaveWord_PostionChange(entity);
        }

        public void DeleteWord_PostionChange(int id)
        {
            _postiontBO.DeleteWord_PostionChange(id);
        }

        public int GetPositionChangeNO(int Year)
        {
            return _postiontBO.GetNOByYear(Year);
        }

        public string ExportWordPositionChange(int id)
        {
            return _postiontBO.ExportWordPositionChange(id);
        }
        
        #endregion



        #region
        public string EmilyExportInfo(string[] Parameters, int TempleteID)
        {
            try
            {
                string path = _interBO.EmilyExportInfo(Parameters, TempleteID);
                return path;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }

        }
        #endregion


    }
}
